const MyPromise = require('./myPromise')

function p1 () {
  return new MyPromise(function (resolve, reject) {
    setTimeout(function () {
      resolve('p1')
    }, 2000)
  })
}
function p2 () {
  return new MyPromise(function (resolve, reject) {
    reject('失败')
    // resolve('成功');  
  })
}

// p2()
//   .then(value => console.log(value))
//   .catch(reason => console.log(reason))

//  const promise = new MyPromise((resolve, reject) => {
  //  setTimeout(() => {
    // reject('失败')
  //  }, 2000)
  //  setTimeout(() => {
  //    reject('失败')
  //  }, 2000)
//  })

// promise.then().then().then(() => {}, val => console.log(val))

// MyPromise.all([1, 2, 3, p1(), p2(), 5]).then(val => console.log(val))

MyPromise.resolve(3).then(res => console.log(res))





